class GamePlayingScene extends GameScene {
    public constructor(user:User) {
        super();
        this.user = user;
        this.start = ()=> {
            //创建游戏场景
            this.createScene();
        }
    }
    /**抓娃娃机 */
    private machine:Machine;
    /**玩家资料 */
    private user:User;
    /**玩家金币显示对象 */
    private userGoldCountDisplay:egret.DisplayObject;
    private helpIconDisplay:egret.DisplayObject;
    private rechargeIconDisplay:egret.DisplayObject;
    /**创建游戏场景 */
    private createScene():void {
        //显示金币数量
        let gold = new egret.Bitmap();
        gold.texture = RES.getRes("gold_png");
        gold.width = gold.height = 51;
        gold.x = 24;
        gold.y = 35;
        this.addChild(gold);
        let x = new egret.TextField();
        x.fontFamily = "Eras Bold ITC";
        x.size = 36;
        x.text = "×"
        x.height = 51;
        x.verticalAlign = "middle";
        x.x = 80;
        x.y = 35;
        this.addChild(x);
        let count = new egret.TextField();
        count.fontFamily = "Eras Bold ITC";
        count.size = 36;
        count.text = ""+this.user.goldCount;
        count.height = 51;
        count.verticalAlign = "middle";
        count.x = 115;
        count.y = 35;
        this.addChild(count);
        this.userGoldCountDisplay = count;
        //添加帮助按钮
        let helpIcon = new egret.Bitmap();
        helpIcon.texture = RES.getRes("help-icon_png");
        helpIcon.x = 554;
        helpIcon.y = 10;
        this.addChild(helpIcon);
        helpIcon.touchEnabled = true;
        helpIcon.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickHelpIcon, this);
        this.helpIconDisplay = helpIcon;
        //添加充值按钮
        let rechargeIcon = new egret.Bitmap();
        rechargeIcon.texture = RES.getRes("recharge-icon_png");
        rechargeIcon.x = 625;
        rechargeIcon.y = 10;
        this.addChild(rechargeIcon);
        rechargeIcon.touchEnabled = true;
        rechargeIcon.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickRechargeIcon, this);
        this.rechargeIconDisplay = rechargeIcon;
        //创建抓娃娃器
        this.machine = myGame.createMachine(this.width, this.height);
        //添加机器到舞台
        this.addChildAt(this.machine, 0);
        //开始游戏
        myGame.startGame();
    }
    private onClickHelpIcon():void {
        top.location.href = "/help"
    }
    private onClickRechargeIcon():void {
        top.location.href = "/recharge"
    }
}
